<template>
	<view>
		<dsl-navbar title="意见反馈" bgTopImg="white" isBack=""></dsl-navbar>
		<view class="padding">
			<view>问题和意见（必填）</view>
			<textarea value="" maxlength="999" placeholder="请详细说明您遇见的问题，以便于我们提供更好的帮助。" v-model="content" />
			<view class="justify-between margin-tb">
				<text>图片（选填、提供问题和截图）</text>
				<text class="text-gray">{{img.length}}/4</text>
			</view>
			<view class="flex flex-wrap">
				<image src="" mode="" v-for="(item,index) in img" class="upload"></image>
				<image src="/static/user/modules/shangchuan.png" mode="" class="upload" @click="upload"></image>
			</view>
			<view>
				<text>联系方式（选填、便于我们与你联系）</text>
			</view>
			<view class="input align-center margin-top-sm">
				<view class="text-lg padding-left" style="color: #9AA2B5;width: 170rpx;">手机号:</view>
				<input type="text" value="" placeholder="请输入手机号" placeholder-style="color:#9AA2B5" v-model="mobile" />
			</view>
			<view class="input align-center margin-top">
				<view class="text-lg padding-left" style="color: #9AA2B5;width: 170rpx;">邮箱:</view>
				<input type="text" value="" placeholder="请输入邮箱" placeholder-style="color:#9AA2B5" v-model="email" />
			</view>
			<button type="default" @click="addFeedbackMen">提交</button>
			<view class="text-center margin-top">
				<text style="color: #9AA2B5;">在线客服 , </text>
				<text style="color: #FFAA1C;">立即咨询</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		updataImgList
	} from "@/common/updataImgList.js"
	import {
		mapState,
		mapActions
	} from 'vuex'
	export default {
		data() {
			return {
				content: '', //问他反馈内容
				img: [], //图片
				mobile: "", //手机号
				email: '', //邮箱
			}
		},
		//生命周期函数
		onReady() {},
		onLoad() {},
		onShow() {},
		methods: {
			...mapActions('system', ['addFeedback']),
			//图片上传
			upload() {
				updataImgList().then(res => {
					console.log('[图片]', res);
					this.$tools.showToast(res.msg)
					if (res.code == 0) {
						if(this.img.length >=4){
							this.$tools.showToast('最大上传4张')
						}else{
							this.img.push(res.data)
						}
					}
				})
			},

			//提交
			addFeedbackMen() {
				if (!this.content) {
					this.$tools.showToast('反馈内容不能为空')
					return
				}
				this.addFeedback({
					content: this.content, //意见反馈
					img: this.img.toString(), //反馈图片
					mobile: this.mobile, //联系方式
					email: this.email, //反馈邮箱
				})
			},
		},
		computed: {},
		components: {},
	}
</script>

<style>
	textarea {
		width: 662rpx;
		height: 200rpx;
		background: #F7F7FB;
		opacity: 1;
		border-radius: 20rpx;
		padding: 10rpx;
		margin-top: 30rpx;
	}

	.upload {
		width: 180rpx;
		height: 214rpx;
		background: #F7F7FB;
		opacity: 1;
		border-radius: 20rpx;
		margin: 20rpx;
	}

	.input {
		width: 662rpx;
		height: 82rpx;
		background: #F7F7FB;
		opacity: 1;
		border-radius: 20rpx;
	}

	input {
		width: 500rpx;
	}

	button {
		width: 600rpx;
		height: 90rpx;
		background: linear-gradient(180deg, #EAA019 0%, #BA4949 100%);
		box-shadow: 0px 0px 20rpx rgba(153, 153, 153, 0.2);
		opacity: 1;
		border-radius: 55rpx;
		color: white;
		margin-top: 100rpx;
	}
</style>
